package com.tonicgb.api.admin.controller;

import com.tonicgb.api.admin.request.LoginRequest;
import com.tonicgb.api.admin.response.LoginResponse;
import com.tonicgb.service.AuthorizationsService;
import com.tonicgb.shared.annotation.ApiResponse;
import com.tonicgb.shared.annotation.PassToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.Valid;

@Api(tags = "Authorizations")
@Controller
@RequestMapping("${adminPath}")
public class AuthorizationsController {

    @Autowired
    private AuthorizationsService auth;

    @PostMapping("/login")
    @ApiOperation(value = "管理员登录",notes = "登录")
    @ApiResponse
    @PassToken
    public LoginResponse login(@RequestBody @Valid LoginRequest loginRequest) throws Exception {
        return auth.login(loginRequest);

    }

}
